package clientGUI;


import clientGUI.adminGUI.*;
import clientGUI.studentGUI.StudentMainGUI;
import clientApp.VirtualAdvisor;

public class MainGUI {
	private VirtualAdvisor myVA;
	
	// constructor
	public MainGUI() throws Exception
	{
		myVA = new VirtualAdvisor();
		
		String username = login();
//		System.out.println("maingui: LOGGED IN AS: " + username + "!!!");
		
		// if student
		if(myVA.isAdmin())
			admin();
		else
			student(username);
	}
	
	/**
	 * login()
	 * logs the user in, using LoginGUI
	 * 
	 * Precondition: none?
	 * Postcondition: gui displayed, logs in user
	 * @return String username
	 * @throws InterruptedException
	 */
	private String login() throws InterruptedException
	{
		// login phase
//		System.out.println("MAINGUI: Begin Login Phase");
		LoginGUI loginConsole = new LoginGUI(myVA);

		// wait until ready to proceed
		while(!loginConsole.ready())
			Thread.sleep(100);
		String username = loginConsole.username();
//		System.out.println("MAINGUI: End Login Phase: username - [" + username + "]");

		return username;
	}
	
	/**
	 * student()
	 * triggers the student user's experience
	 * 
	 * Precondition: valid username inputted
	 * Postcondition: GUI displayed
	 * @param username
	 */
	private void student(String username)
	{
//		System.out.println("Student Logged in");
		String userfullname = "USER NAME";
		// generate schedule
		StudentMainGUI studentGUIconsole = new StudentMainGUI(myVA);
	}
	
	/**
	 * admin()
	 * triggers admin user's experience
	 * 
	 * Precondition: user logged in as admin
	 * Postcondition: shows AdminGUI
	 */
	private void admin()
	{
		AdminGUI adminConsole = new AdminGUI(myVA);
	}	
}